Ignore icons if they would make the request large enough to cause Xlib to
authorMatthias Clasen <mclasen@redhat.com>
Tue, 8 Nov 2005 18:26:37 +0000 (18:26 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Tue, 8 Nov 2005 18:26:37 +0000 (18:26 +0000)
2005-11-08  Matthias Clasen  <mclasen@redhat.com>

* gdk/x11/gdkwindow-x11.c (gdk_window_set_icon_list): Ignore
icons if they would make the request large enough to cause
Xlib to loose the connection.  (#320909, Claudio Saavedra)

ChangeLog
ChangeLog.pre-2-10
gdk/x11/gdkwindow-x11.c

index 06fe82a47ed1becb25a77af481d4f43a1ce4516a..516c9856bc0527280cb55aaefeb3ccf226ddddd5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2005-11-08  Matthias Clasen  <mclasen@redhat.com>
+
+       * gdk/x11/gdkwindow-x11.c (gdk_window_set_icon_list): Ignore
+       icons if they would make the request large enough to cause
+       Xlib to loose the connection.  (#320909, Claudio Saavedra)
+
 2005-11-08  Michael Natterer  <mitch@imendio.com>
 
        * gdk/gdk.symbols
index 06fe82a47ed1becb25a77af481d4f43a1ce4516a..516c9856bc0527280cb55aaefeb3ccf226ddddd5 100644 (file)
@@ -1,3 +1,9 @@
+2005-11-08  Matthias Clasen  <mclasen@redhat.com>
+
+       * gdk/x11/gdkwindow-x11.c (gdk_window_set_icon_list): Ignore
+       icons if they would make the request large enough to cause
+       Xlib to loose the connection.  (#320909, Claudio Saavedra)
+
 2005-11-08  Michael Natterer  <mitch@imendio.com>
 
        * gdk/gdk.symbols
index 1831b73de8e4eb521094eeddb078edcb8f31c78c..cdbe6282fc40dee22c39c62416c023c1a0353d21 100644 (file)
@@ -4017,6 +4017,12 @@ gdk_x11_window_set_user_time (GdkWindow *window,
   toplevel->user_time = timestamp_long;
 }
 
+#define GDK_SELECTION_MAX_SIZE(display)                                 \
+  MIN(262144,                                                           \
+      XExtendedMaxRequestSize (GDK_DISPLAY_XDISPLAY (display)) == 0     \
+       ? XMaxRequestSize (GDK_DISPLAY_XDISPLAY (display)) - 100         \
+       : XExtendedMaxRequestSize (GDK_DISPLAY_XDISPLAY (display)) - 100)
+
 /**
  * gdk_window_set_icon_list:
  * @window: The #GdkWindow toplevel window to set the icon of.
@@ -4045,6 +4051,7 @@ gdk_window_set_icon_list (GdkWindow *window,
   gint x, y;
   gint n_channels;
   GdkDisplay *display;
+  gint n;
   
   g_return_if_fail (GDK_IS_WINDOW (window));
 
@@ -4055,7 +4062,7 @@ gdk_window_set_icon_list (GdkWindow *window,
   
   l = pixbufs;
   size = 0;
-  
+  n = 0;
   while (l)
     {
       pixbuf = l->data;
@@ -4064,8 +4071,16 @@ gdk_window_set_icon_list (GdkWindow *window,
       width = gdk_pixbuf_get_width (pixbuf);
       height = gdk_pixbuf_get_height (pixbuf);
       
+      /* silently ignore overlarge icons */
+      if (size + 2 + width * height > GDK_SELECTION_MAX_SIZE(display))
+       {
+         g_warning ("gdk_window_set_icon_list: icons too large");
+         break;
+       }
+     
+      n++;
       size += 2 + width * height;
-
+      
       l = g_list_next (l);
     }
 
@@ -4073,7 +4088,7 @@ gdk_window_set_icon_list (GdkWindow *window,
 
   l = pixbufs;
   p = data;
-  while (l)
+  while (l && n > 0)
     {
       pixbuf = l->data;
       
@@ -4106,6 +4121,7 @@ gdk_window_set_icon_list (GdkWindow *window,
        }
 
       l = g_list_next (l);
+      n--;
     }
 
   if (size > 0)